package com.wfw.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.wfw.model.ProductInfo;
import com.wfw.utils.BeanConvertUtil;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品详情
 */
@Data
public class ProductInfoVo {
    @JsonProperty("id")
    private String productId;

    @JsonProperty("name")
    private String productName;

    @JsonProperty("price")
    private BigDecimal productPrice;

    @JsonProperty("description")
    private String productDescription;

    @JsonProperty("icon")
    private String productIcon;

    public ProductInfoVo convertFor(ProductInfo productInfo){
        ProductInfoConvertToVo productInfoConvertToVo=new ProductInfoConvertToVo();
        return productInfoConvertToVo.convert(productInfo);
    }

    private class ProductInfoConvertToVo implements BeanConvertUtil<ProductInfoVo, ProductInfo>{

        @Override
        public ProductInfoVo convert(ProductInfo productInfo) {
            ProductInfoVo productInfoVo=new ProductInfoVo();
            BeanUtils.copyProperties(productInfo,productInfoVo);
            return productInfoVo;
        }
    }
}
